package com.qch;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.registry.Registry;
import org.apache.dubbo.registry.RegistryFactory;

/**
 * @Author qch
 * @Date 2021/2/16
 */
public class DubboRouterMain {
    public static void main(String[] args) {
        //注册中心的工厂对象
        RegistryFactory registryFactory = ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension();
        //获取注册中心
        Registry registry = registryFactory.getRegistry(URL.valueOf("zookeeper://192.168.142.128:2181"));
        //注册路由规则
        registry.register(URL.valueOf("condition://0.0.0.0/com.qch.service.HelloService?category=routers&force=true&dynamic=true&rule="+URL.encode("=>host!=192.168.142.1")));
    }
}
